
#include <stdio.h>
#include "esp_log.h"
#include "driver/i2c.h"
#include "sdkconfig.h"
#include "ina226.h"
#include "bt_spp.h"
#include "driver/gpio.h"
#include "LED_gpio.h"

static const char *TAG = "main";
Ina226 ina((i2c_port_t)CONFIG_I2C_MASTER_PORT_NUM, CONFIG_I2C_MASTER_SDA, CONFIG_I2C_MASTER_SCL);
extern uint32_t bt_handle;
LED_gpio led(GPIO_NUM_19);

extern "C" void app_main(void)
{
    ina.INA226_Init();
    bt_spp_init();
    led.LED_Init();
    ESP_LOGI(TAG, "Initial finished");
    while (1)
    {
        /* code */
        if(bt_handle!=0){
            ina.INA226_GetShunt_Current();
            ina.INA226_GetVoltage();
            bt_spp_printf("%4.3f, %4.3f\n", ina.Voltage, ina.Curent);
            led.LED_Blink();
        }
        else{
            led.LED_Bright();
        }
        vTaskDelay(1);
    }
}
